package com.example.service.Impl;

import com.example.domain.OrderDetail;
import com.example.domain.Orders;
import com.example.mapper.OrderDetailMapper;
import com.example.mapper.OrdersMapper;
import com.example.service.IOrderDetailService;
import com.example.service.ex.InsertException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderDetailServiceImpl implements IOrderDetailService {
    @Autowired
    private OrderDetailMapper orderDetailMapper;
    @Override
    public void save(List<OrderDetail> list) {

        //遍历传递的集合对象进行添加
        for (OrderDetail orderDetail :list) {
            int insert = orderDetailMapper.insert(orderDetail);
            if (insert<=0){
                throw new InsertException("添加数据时产生未知的异常");
            }
        }

    }
}
